﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using YQHL.GS.Client;
using YQHL.GS.Model;

namespace YQHL.GS
{
    public class AppClient
    {
        /// <summary>
        /// 查询银行流水
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public JArray GetBankData(PageQuery query)
        {
            var oBody = new JObject();
            oBody["Type"] = "SELECT_BANK_DETAILS";
            oBody["Query"] = JToken.FromObject(query);
            var resonObj = HttpClient.Send(oBody, Config.ServerUrl);

            if (resonObj.GetValue("State").ToObject<int>() == 1)
            {
                return resonObj.GetValue("Data") as JArray;
            }
            else
            {
                throw new Exception("请求异常：" + resonObj.GetValue("Msg").ToObject<string>());
            }
        }

        /// <summary>
        /// 查询银行余额
        /// </summary>
        /// <param name="accountArry">用户名Arry</param>
        /// <returns></returns>
        public JArray GetAccountCent(List<string> accountArry)
        {
            var oBody = new JObject();
            oBody["Type"] = "SELECT_BANK_BLANCE";
            oBody["AccountArry"] = JToken.FromObject(accountArry);
            var resonObj = HttpClient.Send(oBody, Config.ServerUrl);

            if (resonObj.GetValue("State").ToObject<int>() == 1)
            {
                return resonObj.GetValue("Data") as JArray;
            }
            else
            {
                throw new Exception("请求异常：" + resonObj.GetValue("Msg").ToObject<string>());
            }
        }
    }
}